//
//  WGDetailDiseasesController.m
//  QuickCure1
//
//  Created by Apple on 16/11/2.
//  Copyright © 2016年 maoge. All rights reserved.
//

#import "WGDetailDiseasesController.h"
#import "Disease.h"
#import <MJRefresh.h>

@interface WGDetailDiseasesController ()

@end

@implementation WGDetailDiseasesController

- (void)viewDidLoad {
   self.title = @"疾病分类明细";    [super viewDidLoad];

   
    self.tableView.mj_header = [MJRefreshGifHeader headerWithRefreshingBlock:^{
        
          [self loadData];
        
    }];
    

    
    [self loadData];
}

#pragma
#pragma mark - 加载数据

-(void)loadData{
    
            [[NetWorkManager sharedManager] loadDiseaseDataWithPageSize:15 ci1_id:(int)self.model.ci1_id page:1 compete:^(NSArray<Disease *> *array, NSError *error) {
    
                if (error) {
    
                    NSLog(@"疾病详情数据加载失败");
                }else{
    
                    if (array) {
                        NSLog(@"疾病详情 ok ");
    
                        self.diseaseList = array;
                        [self.tableView reloadData];
                        
                        [self.tableView.mj_header endRefreshing];
                      }
                 }
            }];
 }

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return self.diseaseList.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"detailDiseaseCell" forIndexPath:indexPath];
    cell.textLabel.text = self.diseaseList[indexPath.row].ci3_name;
    
    cell.textLabel.textColor = [UIColor jq_colorWithHex:kThemeTextColor];
    

    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [self.navigationController popViewControllerAnimated:YES];
    
    //获取当期选择的cell
    
    NSString *ditailDisease = self.diseaseList[indexPath.row].ci3_name;
    
    [[NSNotificationCenter defaultCenter] postNotificationName:kClickDetailCellNotiCation object:ditailDisease];
    
}

@end
